#include<iostream>
#include<cstring>
#include<queue>
using namespace std;
typedef pair<int, int> PII;
const int N=35;
char arr[N][N];
int sign[N][N];
int ret=1e5, cnt;
int n, m, x, y;
queue<PII> q;
int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};
void dfs()
{
    while(q.size())
    {
        auto ch=q.front(); q.pop();
        int x=ch.first, y=ch.second;
        for(int k=0; k<4; k++)
        {
            int i=x+dx[k], j=y+dy[k];
            if(i<1 || j<1 || i>n || j>m) continue;
            if(sign[i][j] != -1) continue;
            if(arr[i][j] == '*') continue;
            sign[i][j]=sign[x][y]+1;
            if(arr[i][j] == 'e') 
            {
                cnt++;
                ret=min(ret, sign[x][y]+1);
                continue;
            }
            q.push({i, j});
        }
    }
    
}

int main()
{
    memset(sign, -1, sizeof sign);
    cin>>n>>m;
    for(int i=1; i<=n; i++)
        for(int j=1; j<=m; j++)
        {
            cin>>arr[i][j];
            if(arr[i][j]=='k') 
            {
                x=i;
                y=j;
            }
        }
    q.push({x, y});
    sign[x][y]=0;
    dfs();
    if(cnt==0) cout<<"-1";
    else cout<<cnt<<" "<<ret;
    return 0;
}
